<!doctype html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <title>桃李科技</title>
    <link rel="stylesheet" href="__EASYUI__/themes/default/easyui.css">
    <link rel="stylesheet" href="__EASYUI__/themes/icon.css">
    <link rel="stylesheet" href="__ADMINCSS__/icon.css">
    <style type="text/css">
    .logo {
        width: 180px;
        height: 50px;
        line-height: 50px;
        text-align: center;
        font-size: 20px;
        font-weight: bold;
        float: left;
        color: #ddd;
    }
    
    .logout {
        float: right;
        /*height:50px;
			line-height: 50px;*/
        padding: 15px 140px 0 0;
        color: #ddd;
    }
    #top{
        height: 60px;
        background: #b3d0ec url(../../../../Public/taoliAdmin/images/bgTop.png) no-repeat;
    }
    </style>
</head>

<body class="easyui-layout">
    <div data-options="region:'north',title:'North Title',split:true,noheader:true" id="top">
        <div class="logo"></div>
        <div class="logout">
            您好,
            <{$Think.session.username}> | <a href="javascript:;" class="easyui-linkbutton" onclick="logout();">退出</a> | <a href="javascript:;" class="easyui-linkbutton" onclick="resetPwd();">修改密码</a>  
        </div>
    </div>
    <div data-options="region:'west',title:'导航',split:true" style="width:200px;">
        <ul id="nav"></ul>
    </div>
    <div data-options="region:'center'" style="padding:5px;background:#eee;">
        <div id="tabs">
            <div title="起始页" style="padding:0 10px; display:block;">
                <div id="container" style="width:100%;height:100%;">
                    <p><!-- 欢迎来到XXXX管理系统 --></p>                
                </div>
            </div>
        </div>
        <form id="fmpwd" method="POST" style="margin: 0;padding:10px 0 0 40px;">
                 <p>   
                    <label for="name">账&nbsp;&nbsp;&nbsp;&nbsp;号:</label>   
                    <input class="easyui-validatebox" type="text" name="username" data-options="required:true" value="<{$Think.session.username}>" />   
                    <input type="hidden" name="id" value="<{$Think.session.userid}>">
                </p>
                <p>   
                    <label for="name">原&nbsp;密&nbsp;码:</label>   
                    <input class="easyui-validatebox" type="password" name="pwd" data-options="required:true" />   
                </p> 
                <p>   
                    <label for="name">新&nbsp;密&nbsp;码:</label>   
                    <input class="easyui-validatebox" type="password" name="newPwd" data-options="required:true" />   
                </p>  
                <p>   
                    <label for="name">密码确认:</label>   
                    <input class="easyui-validatebox" type="password" name="renewPwd" data-options="required:true" />   
                </p>
          </form>
    </div>
    <div data-options="region:'south',title:'South Title',split:true,noheader:true" style="height:30px;line-height:23px;text-align:center;">
        &copy;&nbsp;桃李科技
    </div>
    <div id="tabsMenu" style="width: 120px;display:none;">
        <div type="refresh">刷新</div>
        <div class="menu-sep"></div>
        <div type="close">关闭</div>
        <div type="closeOther">关闭其他</div>
        <div type="closeAll">关闭所有</div>
    </div>
    <script src="__EASYUI__/jquery.min.js"></script>
    <script src="__EASYUI__/jquery.easyui.min.js"></script>
    <script src="__EASYUI__/locale/easyui-lang-zh_CN.js"></script>
    <script src="__ADMINJS__/common.js"></script>
    <script type="text/javascript">
    var nurl = '__URL__';
    // var containerH=$('#tabs').height();
    </script>
    <script type="text/javascript">
    var _nav, _tabs, _tabsMenu;
    $(function() {
        _nav = $('#nav');
        _tabs = $('#tabs');
        //导航栏 树形
        _nav.tree({
            // url:'__APP__/Admin/Index/getNav',

            data: [{
                "id": 1,
                "text": "学员管理",
                "iconCls": "icon-save",
                "children": [{
                    "text": "学员信息",
                    "state": "open",
                    'url': "/Admin/Student/studentList",
                },{
                    "text": "签到记录",
                    "state": "open",
                    'url': "/Admin/Sign/signList",
                },{
                    "text": "请假记录",
                    "state": "open",
                    'url': "/Admin/Absent/absentList",
                },{
                    "text": "优惠卡",
                    "state": "open",
                    'url': "/Admin/Prompt/promptList",
                }
                ]
            },
            // {
            //     "id": 2,
            //     "text": "系统管理",
            //     "iconCls": "icon-save",
            //     "children": [{
            //         "text": "配置",
            //         "state": "open",
            //         'url': "",
            //     }]
            // }
            
            ],
            lines: true,
            loadFilter: function(rows) {
                $(rows).each(function() {
                    $(this)[0].iconCls = $(this)[0].iconcls;
                    //console.log($(this)[0]);	
                })

                return rows;
            },
            onLoadSuccess: function(node, data) {
                var _this = this;
                if (data) {
                    $(data).each(function(index, value) {
                        if (this.state == 'closed') {
                            $(_this).tree('expandAll');
                        }
                    })
                }
            },
            onClick: function(node) {
                //console.log(node);
                if (node.url) {
                    if (_tabs.tabs('exists', node.text)) {
                        _tabs.tabs('select', node.text);
                    } else {
                        _tabs.tabs('add', {
                            title: node.text,
                            closable: true,
                            iconCls: node.iconCls,
                            href: node.url,
                            tools: [{
                                iconCls: 'icon-mini-refresh',
                                handler: function() {
                                    refreshTab(node.text);
                                }
                            }]
                        });
                    }
                }
            }
        });

        //中央 tab 标签页
        _tabs.tabs({
            fit: true,
            border: false,
            onContextMenu: function(e, title) {
                e.preventDefault();
                _tabsMenu.menu('show', {
                    left: e.pageX,
                    top: e.pageY
                }).data('tabTitle', title);
            }
        })

        _tabsMenu = $('#tabsMenu').menu({
            onClick: function(item) {
                var curTabTitle = $(this).data('tabTitle');
                var type = $(item.target).attr('type');

                if (type === 'refresh') {
                    refreshTab(curTabTitle);
                    return;
                }

                if (type === 'close') {
                    var t = _tabs.tabs('getTab', curTabTitle);
                    if (t.panel('options').closable) {
                        _tabs.tabs('close', curTabTitle);
                    }
                    return;
                }

                var allTabs = _tabs.tabs('tabs');
                var closeTabsTitle = [];

                $.each(allTabs, function() {
                    var opt = $(this).panel('options');
                    if (opt.closable && opt.title != curTabTitle && type === 'closeOther') {
                        closeTabsTitle.push(opt.title);
                    } else if (opt.closable && type === 'closeAll') {
                        closeTabsTitle.push(opt.title);
                    }
                });

                for (var i = 0; i < closeTabsTitle.length; i++) {
                    _tabs.tabs('close', closeTabsTitle[i]);
                }
            }
        });
    })

    function logout() {
        $.post('/index.php/Admin/Index/logout')
            .then(function(data) {
                location.href = "/index.php/Admin/Index/index";
            })
    }

    //刷新 tabs 页面
    function refreshTab(title) {
        var tab = _tabs.tabs('getTab', title);
        _tabs.tabs('update', {
            tab: tab,
            options: tab.panel('options')
        });
    }

    $('#fmpwd input[name=newPwd]').validatebox({
        required:true,
        validType:'length[6,30]',
        missingMessage:'请输入管理员密码',
        invalidMessage:'管理员密码在6-30位',
    })
    main={
        modifyPWD:function(){
            if($('#fmpwd input[name=newPwd]').val()!=$('#fmpwd input[name=renewPwd]').val()){
                $.messager.alert('警告','两次新密码不同哦~');
                return;
            }
            fmpwd=$('#fmpwd');
            var us=fmpwd.form('serialize');
            $.messager.progress({
                text: '正在处理...',
            });
            $.post('<{:U('resetPWD')}>',{user:JSON.stringify(us)}).then(function(data){
                $.messager.progress('close');
                if (data.status == '200') {
                    $.messager.show({
                        title: '成功',
                        msg: data.msg,
                        timeout: 1000,
                        showType: 'slide'
                    });
                    fmpwd.dialog('close');
                    setTimeout(function(){
                        window.location.href='<{:U("Index/Index")}>';
                    },2000)
                    // tbTask.datagrid('reload');
                } else {
                    $.messager.show({
                        title: 'Error',
                        msg: data.msg
                    });
                }
            })
        }
    }
    function resetPwd(){
        $('#fmpwd').dialog({
            width: 350,
            title: '密码修改',
            iconCls: 'icon-add',
            modal: true,
            closed: true,
            buttons: [{
                text: '保存',
                iconCls: 'icon-save',
                handler: function() {
                    main.modifyPWD();
                }
            }, {
                text: '取消',
                iconCls: 'icon-redo',
                handler: function() {
                    $('#fmpwd').dialog('close');
                }
            }]
        }).dialog('open');
    }
    </script>
</body>

</html>
